import request from '@/router/axios';
import { baseUrl } from '@/config/env';

export const listProject = (data) => request({
    url: baseUrl + '/generator/project/listProject',
    method: 'get',
    params: data
});

export const addProject = (data) => request({
    url: baseUrl + '/generator/project',
    method: 'post',
    data: data
});

export const updateProject = (data) => request({
    url: baseUrl + '/generator/project',
    method: 'put',
    data: data
});

export const removeProject = (projectId) => request({
    url: baseUrl + '/generator/project/'+projectId,
    method: 'delete'
});

export const testDb = (data) => request({
    url: baseUrl + '/generator/dynamic/test',
    method: 'post',
    data:data
});

export const dbTables = (dbId) => request({
    url: baseUrl + '/generator/dynamic/'+dbId,
    method: 'get'
});

export const genScaffold = (projectId) => request({
    url: baseUrl + '/generator/gen/genScaffold',
    responseType: 'blob',  // 获取二进制数据
    method: 'post',
    data: projectId
    // params: {
    //     projectId:projectId
    // }
});

export const genFun = (data) => request({
    url: baseUrl + '/generator/gen/genFun',
    responseType: 'blob',  // 获取二进制数据
    method: 'post',
    data:data
});


export const syncField = (data) => request({
    url: baseUrl + '/generator/gen/syncField',
    method: 'post',
    data:data
});